//
//  SSMealView.swift
//  拾舍清洁
//
//  Created by sky.wei on 2023/6/8.
//

import UIKit

public typealias SSMealViewClosure = (_ contentView: SSMealView)->()

public class SSMealView: UIView {
    
    var resultClosure: SSMealViewClosure?     // 闭包
    var topTextLab = UILabel()
    var bottomTextLab = UILabel()
    var currentTag:Int = 0
    
    override open func awakeFromNib() {
        super.awakeFromNib()
        
        self.layer.cornerRadius = 10
        self.layer.masksToBounds = true
        self.layer.borderWidth = 1
        self.layer.borderColor = UIColor(hex: "#F3F3F3")?.cgColor
  
        let topTextLab = UILabel(frame: CGRect(x: 0, y: 0, width: 106, height: 36))
        topTextLab.textAlignment = .center
        topTextLab.text = "A2套餐"
        topTextLab.font = UIFont.boldSystemFont(ofSize: 16)
        self.topTextLab = topTextLab
        self.addSubview(topTextLab)
        
        let bottomTextLab = UILabel(frame: CGRect(x: 0, y: topTextLab.frame.maxY, width: 106, height: 28))
        bottomTextLab.textAlignment = .center
        bottomTextLab.text = "50次-1周1次"
        bottomTextLab.font = UIFont.systemFont(ofSize: 12)
        bottomTextLab.textColor = UIColor(hex: "#AEAEB2")
        self.bottomTextLab = bottomTextLab
        topTextLab.isUserInteractionEnabled = true
        bottomTextLab.isUserInteractionEnabled = true
        self.addSubview(bottomTextLab)
        
        let tapGes = UITapGestureRecognizer(target: self, action: #selector(tapedTitleLabel(_:)))
        self.addGestureRecognizer(tapGes)
        
    }
    
    @objc private func tapedTitleLabel(_ tapGes : UITapGestureRecognizer) {
        
        print("111")
        
        
        resultClosure?(self)
    }
    
    func mealResult(_ finished: @escaping SSMealViewClosure) {
        resultClosure = finished
    }
    
    
    
}
